Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter System Testing #33

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft

Parameter System Testing #33

wants to merge 20 commits into from

Conversation

Jbsco
Copy link
Collaborator

@Jbsco Jbsco commented Aug 22, 2024

This draft pull request includes Python scripts which can be used with COSMOS to test parameter system functionality, namely table validate and table update commands. A mock table is generated as a byte array, and various responses are scintillated by sending commands and checking the Software_Status_Packet that is returned.

test/scripts/update-param-sys.py Outdated Show resolved Hide resolved
cmd("Linux_Example Command_Router_Instance-Noop_Arg with Value 1")
wait(1.0)
# Check successful command count is 2 and that the last success was Noop_Arg with last Value 1:
check_formatted("Linux_Example Software_Status_Packet Command_Router_Instance.Command_Success_Count.Value == '2'")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. To improve this pattern for more general use I suggest the following:

  • Is there a wait-on-value directive in COSMOS? Ideally you would just be waiting for the condition that the command success count is == 2, or timeout if it does not reach that? Waiting for a time is brittle and artificially slow. This could be an issue when we want to start running tests as fast as possible with randomized inputs.
  • We should wrap this logic into a function that does the following: 1) Check the current value of Command_Success_Count (and Command_Fail_Count too) and save them off 2) send command 3) wait for command success count to increment and return, or time out and check command fail count to see if it has incremented 4) return value of 0 for success, 1 for fail, 2 for timeout (or something like this).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably also want a function that does the opposite. If the former function was called wait_for_cmd_success we would also want one that is wait_for_cmd_failure

Copy link
Collaborator Author

@Jbsco Jbsco Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a wait-on-value directive in COSMOS?

wait_check is similar to the check_formatted pattern, but adds a timeout argument. Switching to this eliminates the need for wait calls. Switched to wait_check in 9b73651.

We should wrap this logic into a function that does the following: [...]
Probably also want a function that does the opposite.

I will try to implement this in a future commit. check_exception allows for checking expressions expected to fail, although I think in all cases, if the API function call causes the script to stop then manual intervention is always required to resume or restart. This behavior may be different when not instrumenting each line.

test/scripts/update-param-sys.py Outdated Show resolved Hide resolved
test/scripts/update-param-sys.py Outdated Show resolved Hide resolved
test/scripts/update-param-sys.py Outdated Show resolved Hide resolved
test/scripts/update-param-sys.py Outdated Show resolved Hide resolved
test/scripts/update-param-sys.py Outdated Show resolved Hide resolved
test/scripts/validate-param-sys.py Outdated Show resolved Hide resolved
test/scripts/validate-param-sys.py Outdated Show resolved Hide resolved
test/scripts/crc_16.py Outdated Show resolved Hide resolved
test/scripts/test_setup.py Show resolved Hide resolved
test/scripts/update-param-sys.py Outdated Show resolved Hide resolved
test/scripts/update-param-sys.py Outdated Show resolved Hide resolved
test/scripts/validate-param-sys.py Outdated Show resolved Hide resolved
test/scripts/validate-param-sys.py Outdated Show resolved Hide resolved
@Jbsco
Copy link
Collaborator Author

Jbsco commented Sep 21, 2024

Since commit 8bc9f2d, it will be necessary to ensure bitstring is installed in the COSMOS Script Runner container. This is needed by the Adamant parameter_table_record Python import. This can be achieved by running:

docker exec -it cosmos-project-openc3-cosmos-script-runner-api sh   

Followed by:

pip install bitstring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants